package com.magenta.maxoptra.routing;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Sergey Grachev
 */
public final class GeoProviderAccessStatistics {

    private static final Map<Long, Long> PROVIDER_LAST_ACCESS = new HashMap<Long, Long>();

    private GeoProviderAccessStatistics() {
    }

    public static void markAccessNow(final Long cid) {
        synchronized (PROVIDER_LAST_ACCESS) {
            PROVIDER_LAST_ACCESS.put(cid, System.currentTimeMillis());
        }
    }

    public static long getLastAccess(final Long cid) {
        synchronized (PROVIDER_LAST_ACCESS) {
            final Long timestamp = PROVIDER_LAST_ACCESS.get(cid);
            return timestamp == null ? 0 : timestamp;
        }
    }
}
